home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / ab20_archive / utilities / emulators / spectrum-1.4.lzh / Spectrum.doc < prev    next >
Text File  |  1992-03-17  |  35KB  |  940 lines

  1.  
  2.  
  3.             Sinclair ZX Spectrum Emulator V1.4     17 Mar 1992
  4.             -----------------------------------
  5.  
  6.  
  7. This program emulates a Sinclair ZX Spectrum 48-kbyte z80-based computer on
  8. any Amiga computer.
  9.  
  10.     +-------------------------------------------------------------------+
  11.     | IMPORTANT:  You need to already own a Spectrum to be able to use  |
  12.     | this program.  This is because I am not taking the risk of        |
  13.     | distributing the Spectrum ROM code.  I think that would probably  |
  14.     | be illegal.  Therefore this archive does not include the Spectrum |
  15.     | ROM code. --- You should supply it independently.            |
  16.     +-------------------------------------------------------------------+
  17.  
  18. The files in this archive may be distributed anywhere provided they are
  19. unmodified and are not sold for profit.  Ownership remains with the author,
  20.  
  21.     Peter McGavin, 86 Totara Crescent, Lower Hutt, New Zealand.
  22.     e-mail: srwmpnm@wnv.dsir.govt.nz .
  23.  
  24.  
  25. I assume you have enough knowledge to manipulate binary files and to transfer
  26. data over a serial line without help.  If you don't know what I'm talking
  27. about, don't try this program.
  28.  
  29.  
  30. Spectrum-00 is an executable for 68000-based Amigas only.
  31.  
  32. Spectrum-10 is for 68010-based Amigas, but also works on higher processors.
  33.  
  34. Spectrum-20 is optimised for 68020/30/40...-based Amigas with fast memory.
  35.  
  36. Spectrum-00-special is for 68000-based Amigas.  It is faster and dangerous.
  37.  
  38.  
  39. The Spectrum-00-special version takes some shortcuts to get some extra speed.
  40. Some games will run 2 or 3 times faster than before, but because of the
  41. shortcuts, not all programs will work.  In the special version:
  42.  
  43.     o  Self-modifying z80 code does not work at all.  This affects some
  44.         games.  It also means that you will only be able to run one
  45.         program and then quit.  If you try to load a second Spectrum
  46.         program, without quitting Spectrum-00-special and re-running
  47.         it first, it very probably won't work.
  48.  
  49.     o  Code is optimised for faster animated graphics and scrolling, at
  50.         the expense of speed when the display is static, so you will
  51.         get faster animated games and slower ray-tracing  :-)
  52.  
  53.     o  The ROM is unprotected.  Note that the standard Spectrum ROM
  54.         corrupts itself.  In particular, location 0 usually gets
  55.         overwritten very quickly, so that NEW does not work any more.
  56.  
  57. Do not try to develop or write Spectrum programs with Spectrum-00-special,
  58. because you will probably lose your work.  It is provided only because it is
  59. significantly faster for running some animated Spectrum games.
  60.  
  61. All the programs require the file "spectrum.rom" (not supplied) in the current
  62. directory, or they will not load.
  63.  
  64. The emulator uses the dreaded move-sr instruction after almost every z80
  65. instruction emulated.  It ran 30-40% slower when I tried replacing the
  66. move-sr instruction with a call to GetCC()!  This is quite exceptional ---
  67. with most programs you wouldn't notice the difference.  Therefore I have
  68. supplied a 68010 version which uses move-ccr instead of move-sr.
  69.  
  70. The Spectrum-20 version uses 68020 addressing modes which are not available
  71. on lower processors.
  72.  
  73. The program has been tested on a 3.5 Mbyte Amiga 500 and on a 2 Mbyte Amiga
  74. 3000 (but it uses only about 300 kbytes).
  75.  
  76. I developed the code, entirely in assembler, in my spare time using z80
  77. emulation code based (originally) on Ulf Nordquist's CP/M emulator (Fred Fish
  78. disk 165).  I have fixed several bugs in the z80 emulation code, and made it
  79. more than twice as fast, but there are still some (very hard to find) bugs.
  80.  
  81.     
  82. Features:
  83. ---------
  84.  
  85. The following Spectrum features are implemented:
  86.  
  87.     screen output in the same resolution and colours as a real Spectrum
  88.         --- includes bright, reverse and flash attributes (looks much
  89.         better than the old TV!)
  90.  
  91.     keyboard implemented at the z80 "in" instruction level.  Note that
  92.         like a real Spectrum you have to hold the key down until it
  93.         registers.  Because the emulator is running slower, you might
  94.         have to hold keys down longer.  More often, you might have to
  95.         hold your fingers off the keyboard for longer.  Make sure the
  96.         Spectrum window is active when you start to type.  See
  97.         Appendix 1 for key map.
  98.  
  99.     kempston joystick implemented at the Z80 "in" instruction level.  This
  100.         uses the rear Amiga gameport.  Note that the joystick is
  101.         active only when the Spectrum window is active.  If another
  102.         Amiga program is currently using the joystick, you will get a
  103.         retry/no-joystick requester.
  104.  
  105.     sound implemented by trapping calls to the "beeper" routine at $03b5
  106.         in the Spectrum rom.  Sound works with all Basic programs and
  107.         some machine code programs, but it won't work with machine
  108.         code programs that bang on the hardware to make sounds.
  109.  
  110.     cassette tape loading, if you have a sound sampler capable of at least
  111.         20 kHz sampling rate attached to your parallel port.  This is
  112.         implemented by trapping calls to the "ld-bytes" routine at
  113.         $056b in the Spectrum rom.  Note that copy-protected games
  114.         with custom loaders cannot always be loaded this way.
  115.  
  116. It is possible to save to and load from amiga disk files.
  117.  
  118.  
  119.  
  120. That Missing File:
  121. ------------------
  122.  
  123. As already mentioned, a vital file is missing.  You must supply an image of
  124. the Spectrum's ROM in the file "spectrum.rom".  The file must be exactly
  125. 16384 bytes long and must contain exactly the same byte sequence as memory
  126. locations 0..16383 in the Spectrum.  There are several ways to get this
  127. across to your Amiga, including:
  128.  
  129.     Use the Sinclair Interface 1 serial port connected to the Amiga's
  130.     serial port.  The data can be transferred using a small BASIC program
  131.     on the Spectrum, then captured on the Amiga with either another small
  132.     program or a terminal emulation program.
  133.  
  134.     Use a Spectrum disk drive system that writes IBM-format sectors, then
  135.     read the diskettes on your Amiga using MSH (Fred Fish disk 382) or
  136.     CrossDOS (commercial) and a sector editor like DiskX (Fred Fish disk
  137.     158).  An MGT PLUS D disk drive will work for this.
  138.  
  139.     Find a program that will read Spectrum cassette tapes through an Amiga
  140.     sound sampler, writing the data to a disk file as it goes.  Kristian
  141.     Nielson (e-mail bombadil@freja.diku.dk) has written a program that
  142.     will do this.  Try looking for specload.lzh at your local PD site.
  143.  
  144. I'll leave it up to you to figure out how to get the data across.  You
  145. could always type it in :-)  There are several third-party books that list
  146. the code, e.g,
  147.  
  148.     "The Complete Spectrum ROM Disassembly" by Dr Ian Logan and Dr Frank
  149.     O'Hara, Melbourne House Software Ltd, ISBN 0 86161 116 0, or
  150.     ISBN 0 86759 117 X, 1983;
  151.  
  152.     "The Spectrum Machine Code Reference Guide" by Richard Ross-Langley,
  153.     Interface Publications, ISBN 0 907563 51 1, September 1983.
  154.  
  155. In fact you can supply any 16384-byte file containing valid z80 code and
  156. called spectrum.rom.  The emulator will transfer z80 control to location 0.
  157. Screen and keyboard hardware is programmed the same as a real Spectrum.
  158. (Once loaded, the first 16384 memory locations are readonly.)
  159.  
  160. Please don't ask me to e-mail spectrum.rom to you, because I won't.
  161.  
  162.  
  163.  
  164. Operation:
  165. ----------
  166.  
  167. You can start the emulator from either the Workbench or SHELL (or CLI).  There
  168. are no command-line parameters.
  169.  
  170. If you use the SHELL (or CLI), spectrum.rom must be in the current directory.
  171. From the workbench, spectrum.rom should be in the same directory as the
  172. program.
  173.  
  174. If the emulator can't find spectrum.rom, then it will display a requester
  175. saying so, and it will not run.
  176.  
  177. To use the ARP file requester, you must have arp.library installed in your
  178. LIBS: directory.
  179.  
  180. The emulator runs in its own custom screen and window.
  181.  
  182. The emulator does not disable multitasking, and it does not interfere with
  183. other tasks (except when loading from a sound sampler).  You can drag the
  184. screen down or click it to the back with the mouse, in the usual way.  (Grab
  185. the screen bar to the left of the window to pull it down.)
  186.  
  187. The emulator lowers its own priority to -5, otherwise it would significantly
  188. slow down other tasks.  Raising the priority back to 0 (e.g, with xoper or
  189. artm) does not significantly speed up the emulator on a standard system.
  190. Raising it higher will prevent most other tasks from running at all.
  191.  
  192. To exit the emulator, do any of the following:
  193.  
  194.     o  click the close box with the left mouse button;
  195.  
  196.     o  select "Quit..." from the Project menu, or
  197.  
  198.     o  press the ESC key.
  199.  
  200.  
  201.  
  202. Menus:
  203. ------
  204.  
  205. Project menu
  206.  
  207.     Load snapshot...  F1
  208.  
  209.     Loads a disk file that has been created with "Save snapshot",
  210.     restoring the state of the system to what it was when the snapshot
  211.     was made.  Any currently loaded Spectrum program is lost.  Uses
  212.     the ARP file requester.
  213.  
  214.     You can use "Load snapshot..." even if the Spectrum has "crashed",
  215.     or if you are running a Spectrum program which does not have a
  216.     "quit" option.
  217.  
  218.     The format of a snapshot file is listed in Appendix 2.
  219.  
  220.     Save snapshot...  F2
  221.  
  222.     Saves the current state of the emulator to a disk file.  The entire
  223.     state of the system is saved, including all 48 kbytes of Spectrum ram
  224.     and the state of the z80 processor.  Uses the ARP file requester.
  225.  
  226.     Help...         HELP
  227.  
  228.     Displays the "Spectrum.help" file, which is a diagram of a real
  229.     Spectrum keyboard.  You need about 70 kb of CHIP ram free for this.
  230.  
  231.     Quit...          ESC
  232.  
  233.     Quits the emulator.  (You get a chance to change your mind.)
  234.  
  235.  
  236. Settings menu
  237.  
  238.     LOAD/MERGE/VERIFY...
  239.  
  240.     Selects what happens when the emulator executes a Spectrum BASIC
  241.     LOAD, MERGE or VERIFY command.
  242.  
  243.     Note that this has nothing at all to do with "Load snapshot", which
  244.     always loads from disk.  What it does do, is to change the behaviour
  245.     of the standard Spectrum BASIC tape loading commands, which are
  246.     normally used to load, merge and verify BASIC programs, array data
  247.     and binary code, from cassette tape.
  248.  
  249.     In fact, this selects what happens when any program (including any
  250.     machine code program) calls the cassette tape loading routine in the
  251.     Spectrum rom.
  252.  
  253.     You have a choice of:
  254.  
  255.         Disk files
  256.  
  257.         Select a disk file using the ARP file requester.  The data
  258.         in the file is interpreted as if it is being read from cassette
  259.         tape.
  260.  
  261.         The first byte in the file is the "header" byte, then the raw
  262.         data, then the checksum byte.
  263.  
  264.         The Spectrum normally reads 2 blocks of data from cassette
  265.         tape, a "header" file followed by the "data" file.  These
  266.         should be stored in 2 separate disk files.  The emulator will
  267.         request both files.  I implemented it this way to allow support
  268.         for "headerless" files which are used by many Spectrum machine
  269.         code programs.
  270.  
  271.         Note that the Spectrum still thinks it is reading from cassette
  272.         tape, so you might see messages like "Start tape now", even
  273.         though it is reading from disk.
  274.  
  275.         If the file you select is not in the correct format, or if the
  276.         checksum is wrong, the Spectrum will usually just request the
  277.         same file again, without any messages, as if it read garbage
  278.         noise from cassette tape.
  279.  
  280.         ProSound
  281.  
  282.         Read data from a ProSound sound sampler connected to the
  283.         parallel port.
  284.  
  285.         Other sampler
  286.  
  287.         Read data from any other kind of sound sampler connected to the
  288.         parallel port.
  289.  
  290.         The sampler must be capable of at least 20 kHz sampling rate
  291.         and it must be connected to the parallel port (not the game
  292.         port).
  293.  
  294.         You should be able to feed standard Spectrum cassette tapes in.
  295.  
  296.         Some copy-protected programs have custom loaders that will not
  297.         work in the emulator.
  298.  
  299.         It is possible to connect the Spectrum EAR output to the sound
  300.         sampler to transfer data directly from your Spectrum.  (Use a
  301.         SAVE command at one end, and a LOAD at the other.)
  302.  
  303.         Important: Interrupts on the amiga are disabled while you are
  304.         loading from a sound sampler.  This will interfere with other
  305.         tasks.  For example, a file transfer running in the background
  306.         will probably fail.
  307.  
  308.         It seems as if the whole amiga has frozen while interrupts are
  309.         disabled.  To restore control, click the left mouse button.
  310.  
  311.     SAVE...
  312.  
  313.     Selects what happens when the emulator executes a Spectrum BASIC
  314.     SAVE command.
  315.  
  316.     Note that this has nothing at all to do with "Save snapshot", which
  317.     always saves to disk.  What it does do, is to change the behaviour
  318.     of the standard Spectrum BASIC SAVE commands, which are normally used
  319.     to save BASIC programs, array data and binary code, to cassette tape.
  320.  
  321.     In fact, this selects what happens when any program (including any
  322.     machine code program) calls the cassette tape saving routine in the
  323.     Spectrum rom.
  324.  
  325.     You have a choice of:
  326.  
  327.         Disk files
  328.  
  329.         Select a disk file using the ARP file requester.  The data
  330.         that would normally be written to cassette tape is written
  331.         to the selected file instead.
  332.  
  333.         The first byte in the file is the "header" byte, then the raw
  334.         data, then a checksum byte.
  335.  
  336.         The Spectrum normally writes 2 blocks of data to cassette
  337.         tape, a "header" file followed by the "data" file.  These
  338.         should be stored in 2 separate disk files.  The emulator will
  339.         request both files.  I implemented it this way to allow support
  340.         for "headerless" files which are used by many Spectrum machine
  341.         code programs.
  342.  
  343.         Note that the Spectrum still thinks it is writing to cassette
  344.         tape, so you might see messages like "Start tape, then press
  345.         any key".
  346.  
  347.         Audio
  348.  
  349.         Not implemented in V1.4.
  350.  
  351.  
  352.  
  353. More on Reading Cassette Tapes:
  354. -------------------------------
  355.  
  356. To load a cassette tape through your sound sampler, enter LOAD "" (that is,
  357. J followed by ALT/P twice, then RETURN).  Now start the cassette tape playing
  358. into your sound sampler.  If it is working, the screen should flash colours,
  359. very much like your Spectrum, and the mouse pointer will be frozen.
  360.  
  361. If you got a file requester instead, then you forgot to select your sound
  362. sampler type for "LOAD/MERGE/VERIFY..." in the "Settings" menu.
  363.  
  364. The MERGE and VERIFY commands should also work, as should things like
  365. LOAD "" CODE, etc.
  366.  
  367. If the screen is mostly yellow and blue, the load is working.  If it is
  368. flashing mostly red, it is either synchronising or not working.  If it is
  369. not flashing at all, it is not working at all.  If it doesn't work, try
  370. adjusting the volume and tone controls on the tape recorder.  If you have
  371. trouble, try adjusting the controls while sampling with software that
  372. came with your sampler.  Ideally, the input should be a square wave which
  373. fills the graphic display.  If it still doesn't work, tell me about it.
  374.  
  375. You should be able to save directly from your Spectrum to the Amiga with a
  376. direct connection --- i.e, no cassette tape or recorder at all.  Use a SAVE
  377. command on the Spectrum and a corresponding LOAD command in the emulator.
  378.  
  379. Loading works by intercepting calls to the LD-BYTES routine at location
  380. $056b in the Spectrum ROM.  If a Spectrum program has its own loading
  381. routine, then it won't work.  Some copy-protected games and fast-loaders
  382. are like that, and they will not work.  On the other hand, some Spectrum
  383. programs call LD-BYTES to load headerless tape files.  Those programs
  384. should work fine.
  385.  
  386. The following sound samplers should be suitable, but I have not had the
  387. opportunity to test any except the first:
  388.  
  389.     o ProSound
  390.  
  391.     o Perfect Sound
  392.  
  393.     o Datel DSS
  394.  
  395.     o Future Sound
  396.  
  397. Note that the tape-loading routine disables interrupts for the whole time
  398. it takes to load a tape.  That greatly exceeds Commodore's recommended
  399. limit of 250 microseconds.  While interrupts are disabled, the mouse
  400. pointer freezes, the keyboard is locked out, all other tasks stop, and any
  401. data arriving at the serial port is lost.  If I knew another way to make
  402. it work, I'd do it that way.  As far as I am aware, all sound sampling
  403. software on the Amiga disables interrupts for excessive periods.  The
  404. Spectrum loader has to interpret the incoming data in real time, which is
  405. quite a lot more than just saving it to a buffer in memory.
  406.  
  407. To break out of the load routine without actually loading anything, press
  408. the left mouse button.  The Spectrum BREAK key (SHIFT/SPACE) won't work in
  409. this situation.
  410.  
  411. If the keyboard doesn't work after you break out with the left mouse
  412. button, it's probably because you accidently deselected the window (by
  413. clicking outside it).  Just click anywhere inside the Spectrum window
  414. and the keyboard will work again.
  415.  
  416. The load routine is based on code kindly provided by Kristian Nielson.
  417. It has been tested on both standard and accelerated amigas.
  418.  
  419.  
  420. General Notes:
  421. --------------
  422.  
  423. o   The emulator runs about 2 to 8 times slower than a real Spectrum, on a
  424.     standard 68000-based A500.  If you are the lucky owner of an Amiga 3000,
  425.     the emulator runs faster than a real Spectrum, but make certain it's
  426.     running out of FAST ram.  If you run it out of CHIP ram, then it's more
  427.     than twice as slow.  I'm afraid the 68000 doesn't have a built-in z80
  428.     emulation mode, and a 3.5 MHz z80 is much harder to emulate than a 6502
  429.     as used in the Commodore 64 and BBC microcomputers.  The Spectrum NEW
  430.     command takes 9.7 seconds on an A500, compared with about 2.0 seconds on
  431.     a real Spectrum, 1.8 seconds on an A3000 (in FAST static-column ram), and
  432.     1.6 seconds on a 33MHz Mega-Midget-Racer with 32-bit ram.
  433.  
  434.  
  435. o   This version of Spectrum uses the blitter to refresh the screen in
  436.     parallel with the emulator.  That is, it uses multi-processing.  Thus,
  437.     the overhead of a z80 instruction writing to the Spectrum's display file
  438.     is minimised.  Before you A3000 owners complain that the 68030 is faster
  439.     than the blitter for blitting, remember that while the blitter is
  440.     refreshing the screen, the 68030 is busy emulating the z80.  The program
  441.     uses QBlit() for concurrency, not OwnBlitter() which would block the z80
  442.     emulator.
  443.  
  444.  
  445. o   I've just about run out of ideas on how to significantly speed up the
  446.     code from what it is now.  One thought is to code some common ROM routines
  447.     in pure 68000.  Obvious candidates are the text output, scrolling, and
  448.     maskable interrupt routines.  Of course this would only speed up programs
  449.     that call the ROM, which excludes most games.  Also, It would probably be
  450.     illegal.  The major speed bottleneck used to be the z80 instruction
  451.     decode.  I've pretty well eliminated that by going to threaded code.  The
  452.     display routines are about as fast as I can get them.  Taking over the
  453.     machine and doing everything at the hardware level would probably give
  454.     only a slight speed improvement, and the program would become much less
  455.     friendly and less portable.
  456.  
  457.  
  458. o   In version 1.4, the following Spectrum features are NOT implemented yet:
  459.  
  460.     border colour (except during cassette tape loading);
  461.  
  462.     saving to cassette tape;
  463.  
  464.     bank roms (e.g, Interface 1);
  465.  
  466.  
  467. o   The following z80 features are NOT properly implemented:
  468.  
  469.     the z80 h processor flag;
  470.  
  471.     the z80 daa instruction (decimal adjust a) --- daa works properly only
  472.         immediately after add, sub, adc or sbc;
  473.  
  474.     the timer interrupt occurs after every 1500 branch, jump, call and
  475.         return z80 machine instructions, instead of every 20 ms.  On
  476.         accelerated amigas, interrupts will not occur any faster than
  477.         every 20 ms.
  478.  
  479.     updating of the flash attribute occurs every 24000 branch, jump, call
  480.         and return z80 instructions, instead of every 320 ms.  On
  481.         accelerated amigas, the flash speed will never be faster than
  482.         every 320 ms.
  483.  
  484.     interrupts and screen updates can occur only immediately after branch,
  485.         jump, call, return and halt z80 machine instructions.
  486.  
  487.     because the emulator is not real-time, the real interval between timer
  488.         interrupts and flash attribute updates depends on the nature
  489.         of the Spectrum program being run.
  490.  
  491.     there might still be rare problems executing certain long,
  492.     self-modifying z80 instructions located at exactly 32763..32766 in z80
  493.     memory, because of the 68000 addressing modes used to load instruction
  494.     operands;
  495.  
  496.     there is at least one other bug I haven't been able to track down yet.
  497.  
  498.  
  499. o   Because it's running slower, maybe now you can get past that "impossible"
  500.     level in your favourite game.
  501.  
  502.  
  503. o   Now you can print Spectrum graphics by transferring to your Amiga.
  504.  
  505.  
  506. o   If you're cross-developing Spectrum software, now you can see which parts
  507.     need speeding up.
  508.  
  509.  
  510. o   I've tested it with several Sinclair Basic programs and all ran perfectly.
  511.  
  512.  
  513. o   I've tried lots machine-code programs and most work ok.  The following
  514.     programs seem to work ok in the emulator:
  515.  
  516.         Zeus Assembler and Monitor
  517.         Scrabble
  518.         Jetset Willy            no sound
  519.         Atic Atac            no sound
  520.         Jetpac                no sound
  521.         Tron                full sound
  522.         The Train Game            no sound
  523.         Backgammon
  524.         PSSST                some sound
  525.         Horace and the Spiders
  526.         Sam Spade            full sound effects
  527.         Draughts
  528.         Sam Stoat            some sound
  529.         3D Deathchase            no sound
  530.         Technician Ted            no sound
  531.         Kosmic Kanga
  532.         Monty Mole
  533.         Talk Chess            no speech, sorry
  534.         Horace Goes Skiing        some sound
  535.         Hungry Horace            some sound
  536.         Star Raid            no sound
  537.         Cyclone                some sound
  538.         Wheelie                no sound
  539.         Full Throttle            no sound
  540.         Mugsy
  541.         Dynamite Dan            no sound
  542.         Dynamite Dan II            full sound effects
  543.         Heathrow            beeps
  544.         IS Chess 48
  545.         Matchpoint
  546.         Max Headroom            no joystick
  547.         Spy vs Spy
  548.         Kong
  549.         The Alchemist
  550.         Daley Decathlon
  551.         Automania
  552.         Penetrator
  553.         Gyron
  554.         Alien8
  555.         Cyberun
  556.         KnightLore
  557.         Batman
  558.         Tomahawk
  559.         Fighter Pilot
  560.         Athena
  561.         Basil the Detective
  562.         Pacland
  563.         Orbix
  564.         Meteor
  565.         Manic Miner
  566.         Madmix
  567.         Kokotoni Wilf
  568.         Ikari Warriers
  569.         Gauntlet
  570.         Dustin
  571.         Ant Attack
  572.  
  573.  
  574.     St Bernard resets the Spectrum at the end of the first level.
  575.  
  576.     SabreWulf runs, except sometimes the rhino runs backwards (very
  577.     amusing).
  578.  
  579.     (If you know why either of these programs don't work, please tell me.)
  580.  
  581.     Note: The Amiga doesn't crash.  If a Spectrum program crashes, you can
  582.     either:  Quit the emulator and continue working on the Amiga, or:
  583.     Press F1 and load another snapshot.
  584.  
  585.     Note: Some of the above have not been tested since Spectrum v0.7 or v0.8.
  586.  
  587.     Another note: Some of the above programs won't load from tape, but they
  588.     will run if you can create a snapshot file somehow (e.g, Mirage Microdriver
  589.     and serial port).
  590.  
  591.  
  592. o   One problem I have had with snapshotting games by transferring a snapshot
  593.     file from the real Spectrum to the amiga, is as follows:  If there is
  594.     non-standard hardware in your real Spectrum (like a non-standard joystick or
  595.     disk drive), and the program knows about the special hardware, then the
  596.     program might have already done a hardware test (before you made the
  597.     snapshot) that makes it believe the special hardware exists permanently.
  598.     Then, when run under the emulator, the program tries to access the
  599.     non-existent hardware and behaves erratically.
  600.  
  601.     What is wrong is that the program was started in one environment (the real
  602.     Spectrum with add-ons) and is now running in another (the plain Spectrum
  603.     emulator).  For example, if your program behaves as if the joystick button
  604.     is continuously pressed (when run in the emulator), maybe it is because
  605.     you made the original snapshot from a Spectrum which has non-standard
  606.     joystick hardware.  See if you can disconnect the joystick interface and
  607.     reload the original program from tape before you make a snapshot.
  608.  
  609.  
  610. o   I am not supplying the source of the emulator yet.
  611.  
  612.  
  613. o   Please report bugs to srwmpnm@windy.dsir.govt.nz.  I'd much prefer bug
  614.     reports like "the `or' instruction doesn't zero the carry flag" to
  615.     "Dan Dare doesn't work".
  616.  
  617.  
  618.  
  619. Appendix 1:  The keyboard:
  620.  
  621. The Spectrum has a weird way of mapping functions to keys that doesn't
  622. translate nicely to the Amiga.  To get a "[" on a real Spectrum, for example,
  623. you press CAPS-SHIFT and SYMBOL-SHIFT together followed by SYMBOL-SHIFT and F.
  624. In the emulator, you do the same thing except CAPS-SHIFT is either of the
  625. SHIFT keys and SYMBOL-SHIFT is either of the ALT keys.  Pressing "[" on the
  626. Amiga keyboard won't work.
  627.  
  628. The following table lists the Amiga key(s) corresponding to each Spectrum key:
  629.  
  630.     Spectrum key        Amiga key
  631.  
  632.     0..9            0..9 (main keyboard or keypad)
  633.     A..Z            A..Z
  634.     SPACE            SPACE
  635.     ENTER            RETURN or ENTER
  636.     CAPS-SHIFT        either SHIFT key
  637.     SYMBOL-SHIFT        either ALT key
  638.  
  639. The following special Amiga keys correspond to Spectrum key combinations.
  640.  
  641.     Amiga key        Spectrum key combination
  642.  
  643.     .            SYMBOL-SHIFT/M
  644.     ,            SYMBOL-SHIFT/N
  645.     ;            SYMBOL-SHIFT/O
  646.     -            SYMBOL-SHIFT/J
  647.     =            SYMBOL-SHIFT/L
  648.     keypad (        SYMBOL-SHIFT/8
  649.     keypad )        SYMBOL-SHIFT/9
  650.     keypad /        SYMBOL-SHIFT/V
  651.     keypad *        SYMBOL-SHIFT/B
  652.     keypad -        SYMBOL-SHIFT/J
  653.     keypad +        SYMBOL-SHIFT/K
  654.     keypad ENTER        ENTER
  655.     keypad .        SYMBOL-SHIFT/M
  656.     left arrow        SHIFT/5
  657.     down arrow        SHIFT/6
  658.     up arrow        SHIFT/7
  659.     right arrow        SHIFT/8
  660.  
  661. ESC quits the emulator (unless you cancel the requester that comes up).
  662.  
  663. HELP displays the Spectrum.help file, which is a diagram of the real Spectrum
  664. keyboard.  (You need about 70 kb of CHIP ram free for this.)
  665.  
  666. F1 brings up the load snapshot requester (provided arp.library is installed).
  667.  
  668. F2 brings up the save snapshot requester (provided arp.library is installed).
  669.  
  670. F3 changes the sampler type for cassette tape loading.
  671.  
  672. All the other Amiga keys do nothing.
  673.  
  674.  
  675.  
  676. Appendix 2:  Snapshot file format:
  677.  
  678. This format is based on the format used by the Mirage Microdriver "Dump"
  679. command.  Snapshot files are always 49179 bytes long.  Note that in the table,
  680. the byte offset starts from 0, not 1.
  681.  
  682.     Byte offset into file        Value
  683.  
  684.     0                i  register
  685.     1                l' register
  686.     2                h' register
  687.     3                e' register
  688.     4                d' register
  689.     5                c' register
  690.     6                b' register
  691.     7                f' register
  692.     8                a' register
  693.     9                l  register
  694.     10                h  register
  695.     11                e  register
  696.     12                d  register
  697.     13                c  register
  698.     14                b  register
  699.     15                iy low register
  700.     16                iy high register
  701.     17                ix low register
  702.     18                ix high register
  703.     19                bit 2 is set if interrupts are enabled
  704.     20                r register
  705.     21                flags register
  706.     22                a register
  707.     23                sp low register
  708.     24                sp high register
  709.     25                interrupt mode (0, 1 or 2)
  710.     26                filler (not used)
  711.     27..49178            48 kbytes ram dump
  712.  
  713.  
  714.  
  715. Appendix 3:  Other Spectrum Emulators:
  716.  
  717.  
  718. When I started this project I did not know of any other Spectrum emulators.
  719. Now I know of at least 8 (eight), including this one, in various stages of
  720. development.
  721.  
  722. 1: This one.
  723.  
  724. 2: The public domain K.G.B. emulator advertised in "Amiga Format".  I have
  725. seen only version 1.2 which does not multitask and does not work properly on
  726. my A3000.
  727.  
  728. 3: An Italian emulator was released (possibly commercially) about 2 years ago.
  729. The version I saw was very bug free and worked on accelerated amigas, but it
  730. did not multitask and was slightly slower than mine.
  731.  
  732. 4: An emulator is under development in Sweden.
  733.  
  734. 5: Another emulator, intended to be commercial, was written in Holland, but it
  735. was never released as far as I know.  From what I have heard about it, it is
  736. much faster than mine.
  737.  
  738. 6: The Whitby Software Spectrum Simulator is a Spectrum ROM rewrite for the
  739. C64.  It runs just fine under TheA64Package and is surprisingly fast.  Because
  740. it is a ROM rewrite and not a z80 emulator, you cannot run z80 machine code
  741. programs (i.e, most games).
  742.  
  743. 7: VGASPEC is a Spectrum emulator for the IBM-PC and clones (not for the
  744. amiga).  A VGA graphics adaptor is required.  I think it was developed in
  745. Spain or Portugal (I don't recognise the language that all the messages are
  746. written in).
  747.  
  748. 8: JPP is another Spectrum emulator for the IBM-PC and clones, developed very
  749. recently in Denmark.  An 80386 and VGA are required.  It is faster than
  750. VGASPEC, and it still has a few obvious bugs, but the author is currently
  751. working hard to fix them.  The name JPP is derived from the keys you press to
  752. get LOAD "".
  753.  
  754.  
  755.  
  756. Appendix 4:   Update Notes:
  757.  
  758.  
  759. v0.0    22 Oct 1990
  760.  
  761. First release.
  762.  
  763.  
  764. v0.1    15 Nov 1990
  765.  
  766. Sped up display code slightly.  Also sped up main instruction decode slightly.
  767. Display flash attribute as reverse.
  768.  
  769.  
  770. v0.2    30 Dec 1990
  771.  
  772. Now use double buffered display and implemented flash attribute properly.
  773. Added error requesters.
  774. Used pc-relative jump tables in z80 emulator --- slightly faster, and much,
  775. much smaller.
  776.  
  777.  
  778. v0.3    20 Jan 1991
  779.  
  780. Changed display routines to update screen periodically instead of after every
  781. z80 instruction that pokes the Spectrum's display file.  Used the blitter for
  782. this, running in parallel with the z80 emulator.  (Only character rows that
  783. have changed since the last screen update are redrawn.)
  784. Reverted to single buffer display and used blitter to implement flash.  (It's
  785. smaller and faster this way.)
  786. Fixed bug where couldn't use path string in arp file requester.
  787.  
  788.  
  789. v0.4
  790.  
  791. Changed the z80 emulator to use threaded code.  Now all that is executed between
  792. each pair of z80 instructions is "move.w (a3)+,d6; jmp table(pc,d6.w)" instead
  793. of about ten 68000 instructions to decode the next z80 opcode byte.  Overheads
  794. introduced are a new 128 kbyte table giving the routine offset for every byte
  795. in z80 ram, and the necessity to write a zero word into this table every time
  796. the emulator writes to z80 ram.  The overall speed increase is about 20%.
  797. Expanded some subroutines to macros and expanded $dd and $fd prefix
  798. instructions to independent code for a slight speed increase.  A side-effect
  799. is that the executable increased in size from 27k to over 40k.
  800. Introduced some bugs during the systematic changes that are proving hard to
  801. track down.
  802.  
  803.  
  804. v0.5     7 Apr 1991
  805.  
  806. Fixed bug in "sra a" instruction.
  807. Fixed bugs in rotate and shift (ix+d) and (iy+d) instructions.
  808. Fixed bugs where used "offset(a4,rr.w)" to address z80 memory space where offset
  809. is -2, -1, 1 or 2.  (Can't use that mode because of the unlikely event of rr.w
  810. being near $8000.)
  811. Implemented mode 2 interrupts.  Low byte of interrupt vector (normally
  812. provided by an external peripheral device) is assumed to be 0.
  813. Increased the interrupt interval from 2500 instructions to every 5000
  814. instructions, because otherwise some programs with their own (mode 2)
  815. interrupt routines overflowed the stack.
  816.  
  817.  
  818. v0.6    23 Apr 1991
  819.  
  820. Fixed bugs in the following z80 instructions:
  821.     ld     ixh,b
  822.     ld    ixh,d
  823.     rl    (ix+dd)
  824.     rr    (ix+dd)
  825.     sla    (ix+dd)
  826.     cpdr
  827. and iy equivalents of the above instructions.
  828. Implemented ini, outi, ind, outd, inir, otir, indr, otdr.  (Out instructions do
  829.     nothing).
  830. Now preserve (otherwise) unused flag bits in push af, pop af and ex af,af'
  831.     (instead of setting them all to 0).
  832. Changed layout of vector table for threaded code (origin now in middle).
  833. Fixed bug in vector table wraparound code (when pc incremented from 32767 to
  834.     32768).
  835. Sped up ram writes by optimising macro for writing a byte to ram.
  836. Added processor type check.  Now you get a requester when you try to run the
  837.     wrong version for your processor type, instead of "Software Error,
  838.     Task Held".
  839. Implemented sound by opening audio.device and trapping calls to the "beeper"
  840. subroutine at $03b5 in Spectrum ROM.
  841.  
  842.  
  843. v0.7
  844.  
  845. Optimised blits to update flash attributes by keeping track of which parts of
  846. the display are flashing and updating only those parts.  That saves a lot of
  847. blits.  No blits are needed at all when there are no flashing characters
  848. displayed.  It used to redraw the entire display for every blink.
  849.  
  850.  
  851. v0.8    13 May 1991
  852.  
  853. Further optimised the display routines by adding a 6144-byte lookup table.
  854.  
  855.  
  856. v0.9    22 Jul 1991
  857.  
  858. Lower task priority to -5 at startup.  This is friendlier to other tasks
  859. because Spectrum is highly CPU intensive.  If Spectrum is running at a higher
  860. priority than another task, then that other task is completely blocked.
  861. Sped up the emulator by 5% by checking for interrupts only after branch, jump,
  862. call and return instructions, instead of after all instructions.
  863. Open gameport.device and emulate Kempston joystick (at Z80 "in" instruction
  864. level) using the rear Amiga gameport.
  865.  
  866.  
  867. v0.9b    1 Sep 1991
  868.  
  869. Implemented all the undocumented z80 sls instructions.
  870. Fixed bug in ld (nn),sp instruction.  (It didn't work at all!)
  871. Implemented the z80 n flag --- all instructions now set/reset the n flag.
  872. Fixed bugs in inc/dec (hl), inc/dec (ix+dd) & inc/dec (iy+dd) (never set v).
  873. The daa instruction now works correctly after add and sub (not just adc & sbc).
  874. Incorporated Kristian Nielson's tape load routine.
  875. Allocate/free misc.resource.
  876. Added "File already exists! Overwrite?" requester (in save snapshot).
  877. Fixed keypad 0 key.
  878. Rationalised keyboard.  Arrow keys are now equivalent to SHIFT+5/6/7/8 instead
  879. of 5/6/7/8 (without the SHIFT).
  880. ESC key quits.
  881. The halt instruction now calls WaitTOF().  (Was too fast.)  The Spectrum Basic
  882. PAUSE function now works correctly.
  883. Added a separate timer task to prevent interrupts occurring too quickly.  The
  884. "flash" rate and keyboard interrupt rates are now more constant.
  885. The HELP key now displays Spectrum.help IFF/ILBM file from current directory.
  886. Reorganised register usage in z80 emulator to try to speed it up (lots of work
  887. but not much success).
  888.  
  889.  
  890. v1.0    9 Nov 1991
  891.  
  892. Implemented menus.
  893. Added noise correction code to cassette tape loader.
  894. Added support for 2 kinds of sound samplers.
  895. Screen to front after error requester in IFF loader.
  896. Use an interrupt server instead of extra task for timer.
  897. Further optimised blitter routines.
  898. Put z80 parity byte in a register (slight speedup).
  899. Implemented ld-bytes and sa-bytes to/from disk.
  900.  
  901.  
  902. v1.1    Dec 1991
  903.  
  904. Created 68020 version (uses 68020/30/40-only addressing modes for extra speed)
  905. Moved z80 address space to FAST RAM with a copy of 16384..22527 in CHIP RAM
  906. (instead of having the whole Z80 address space in CHIP RAM).
  907. Added more undocumented z80 instructions.
  908. Sped up display routines by changing update algorithm.  Animated graphics and
  909. scrolling are now faster by a factor of 2 or 3.
  910.  
  911.  
  912. v1.2    7 Jan 1992
  913.  
  914. Rewrote joystick handling routines to avoid continuous polling.
  915.  
  916.  
  917. v1.3    Feb 1992
  918.  
  919. Implemented a much faster algorithm for handling z80 prefix instructions that
  920. was suggested to me by Richard Carlsson.
  921. Preserve high bit of R register between LD R,A and LD A,R, and also in snapshot
  922. files.  Tomahawk works now.
  923. GetCC() is now documented to preserve d0/d1/a0/a1.  Fixed movesr macro.
  924. Mode 2 interrupts assume $ff is on the external bus, not $00.  This change
  925. fixed quite a few games.
  926. Fixed glaring bug in "set 4,l" instruction.  Sabre Wulf, Fighter Pilot, Basil
  927. the Detective, Athena and lots of other programs work now.
  928. Changed implementation of daa instruction to speed up add/adc/sub/sbc instrs.
  929. Use blitter to do comparisons as well as copies in display updater.
  930. Sped up CPU computation of blitter attribute masks in display updater.
  931. Display updater now translates black to bright black on the fly.  This leaves a
  932. colour register free for the border colour (one day).
  933. Fixed bug in display updater that caused flashing to fail sometimes.
  934.  
  935.  
  936. v1.4    17 Mar 1992
  937.  
  938. Changed ld-bytes ROM patch entry point from $0556 to $056b to be compatible
  939. with more programs.
  940.